package com.huaruan.food.biz.android.imp;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.BeanUtils;

import com.huaruan.food.biz.android.IAndroidManager;
import com.huaruan.food.dao.IDao;
import com.huaruan.food.entity.OrderInfo;
import com.huaruan.food.javabean.AndroidOrder;

public class AndroidManagerImp implements IAndroidManager {
	private IDao dao;
	public void setDao(IDao dao){
		this.dao = dao;
	}
	@Override
	public List<AndroidOrder> findNotPayOrderByDeskNo(String deskNo) {
		//from order_info where desk_no='23' and state =1 order by create_time desc
		String hql = "from OrderInfo where deskNo=? and state=1 order by createTime desc";
		//List<OrderInfo> list = dao.find(hql, params);
		return null;
	}

	@Override
	public List<AndroidOrder> findOrderByOrderNo(String orderNo) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public List<AndroidOrder> getNotPayOrders() {
		return findOrderByState(1);
	}
	@Override
	public List<AndroidOrder> findOrderByState(Integer state) {
		List<OrderInfo> list = dao.findByNamedQuery("findOrderInfos", state);
		List<AndroidOrder> result = null;
		if(null!=list){
			result = new ArrayList<AndroidOrder>(0);
			for (OrderInfo order : list) {
				AndroidOrder ao = new AndroidOrder();
				BeanUtils.copyProperties(order, ao);
				result.add(ao);
			}
		}
		return result;
	}
	
	

}
